package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.CwkcDao;
import com.hnkywl.sts.dao.report.YhckDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-20
 * Time: 下午6:19
 * To change this template use File | Settings | File Templates.
 */
@Service
public class YhckService {
    private YhckDao yhckDao;

    /**
     * 银行存款
     *
     * @param gsid
     * @param endDate
     * @return
     */
    public String yhckList(Long gsid, Date endDate,Long zhlx,Integer pageNo, Integer pageSize) {
        Map<String, List> result = yhckDao.yhckList(gsid, endDate,zhlx, pageNo,  pageSize);
        List<Map> rows = result.get("rows");
        List<Map> footer = result.get("footer");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String footerJson = gson.toJson(footer);
        String json = "{\"rows\":" + rowsJson + ",\"footer\":" + footerJson + "}";
        return json;
    }


    public String yhckmxList(Long gsid,Long khhId,Date startDate, Date endDate,Integer pageNo, Integer pageSize) {
        Map<String, List> result = yhckDao.yhckmxList(gsid, khhId,startDate,endDate, pageNo,  pageSize);
        List<Map> rows = result.get("rows");
        List<Map> footer = result.get("footer");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String footerJson = gson.toJson(footer);
        String json = "{\"rows\":" + rowsJson + ",\"footer\":" + footerJson + "}";
        return json;
    }

    @Autowired
    public void setYhckDao(YhckDao yhckDao) {
        this.yhckDao = yhckDao;
    }
}
